var number = 9;
var startingPage;
//获取传递过来的值
var url = decodeURI(window.location.href);
var aa = url.indexOf('=');
if (aa > -1) {
    url = url.substring(aa + 1);
}

//评分
function starLoad() {
    ul = document.getElementById('star');
    lis = ul.getElementsByTagName('li');
    for (var i = 0; i < lis.length; i++) {
        lis[i].onclick = function () {
            //被用户点击后弹框并提示分数
            //获取当前对象的对象名
            var className = this.className;//nostart
            //重新定义class,并弹出评分
            ul.className = "nostar " + className;
            score = this.getElementsByTagName('a')[0].title;
        }
    }
}

function submitContactData() {
    var plaintName = $("#plaintName").val();
    var plaintConter = $("#plaintConter").val();
    var data = {
        "userPlaintName": plaintName,
        "userPlaintConter": plaintConter,
        "userPlaintGrade": score,
        "orderID": url
    };
    $.ajax({
        url: "insertUserPlaintByUserPlaintData",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(data),
        async: false,
        success: function (data) {
            if (data.code == 200) {
                window.location.href = urls + "web-account.html";
            } else {
                Swal.fire("提示", "新增数据失败", "error");
            }
        }
    });
}

$(function () {
    var DATA = '';
    var data_1 = '';
    $.ajax({
        url: "JudgeLogin_4",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            if (data.code == 500) {
                DATA += " <li class=\"header-btn\">\n" +
                    "                                    <a href=\"web-login.html\" class=\"item-btn\"><i class=\"fas fa-plus\"></i>登录</a>\n" +
                    "                                </li>"
            } else {
                DATA += " <li class=\"header-login-icon\">\n" +
                    "                                    <a href=\"web-account.html\" class=\"color-light\" data-toggle=\"tooltip\"\n" +
                    "                                       data-placement=\"top\" title=\"Login/Register\">\n" +
                    "                                        <i class=\"far fa-user\">我的</i>\n" +
                    "                                    </a>\n" +
                    "                                </li>\n" +
                    "                                <li class=\"header-btn\">\n" +
                    "                                    <a  onclick='tuichu()' class=\"item-btn\"><i class=\"fas fa-plus\"></i>退出</a>\n" +
                    "                                </li>";
                data_1 += " <button type=\"submit\" class=\"item-btn\" onclick=\"submitContactData()\">\n" +
                    "                                        提交\n" +
                    "                                    </button>";
            }
            $("#userData").html("");
            $("#userData").append(DATA);
            $("#data_1").html("");
            $("#data_1").append(data_1);
        }
    });
    starLoad();
});